package io.github.uicdb.et.block;

import io.github.uicdb.et.ModElements;
import io.github.uicdb.et.capability.IElementalHandler;
import lombok.RequiredArgsConstructor;
import net.minecraft.world.inventory.ContainerData;
import org.checkerframework.common.value.qual.IntRange;

@RequiredArgsConstructor
public class ElementalContainerData implements ContainerData {
    final IElementalHandler elementalHandler ;
    @Override
    public int get(int i) {
        return elementalHandler.getElemental(byIndex(i));
    }

    @Override
    public void set(int i, int i1) {
        if (i1 == 0) elementalHandler.removeElemental(ModElements.values()[i]);
        else
            elementalHandler.setElemental(byIndex(i), i1);
    }

    @Override
    public int getCount() {
        return ModElements.values().length;
    }
    private ModElements byIndex(@IntRange(from = 0, to = 6) int index) {
        return ModElements.values()[index];
    }
}
